package com.zxjbyte.yiyi.module.plugin.monitor.controller;

import com.zxjbyte.yiyi.framework.common.constant.Constant;
import com.zxjbyte.yiyi.framework.common.domain.api.R;
import com.zxjbyte.yiyi.module.plugin.monitor.domain.response.NetworkInfoResponse;
import com.zxjbyte.yiyi.module.plugin.monitor.domain.response.RedisInfoResponse;
import com.zxjbyte.yiyi.module.plugin.monitor.domain.response.ServerInfoResponse;
import com.zxjbyte.yiyi.module.plugin.monitor.service.IMonitorService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author zhangxingjia
 * @Date 2024/6/20 16:23
 * @Version: 1.0
 */
@Tag(name = "监控控制器")
@RestController
@RequestMapping(value = Constant.BASE_PATH_PLUGIN + "/monitor")
public class MonitorController {

    @Resource
    private IMonitorService monitorService;

    @Operation(summary = "获取服务器监控信息")
    @GetMapping("/serverInfo")
    public R<ServerInfoResponse> serverInfo() {
        return R.data(monitorService.serverInfo());
    }

    @Operation(summary = "获取redis缓存监控信息")
    @GetMapping("/redisInfo")
    public R<RedisInfoResponse> redisInfo() {
        return R.data(monitorService.redisInfo());
    }

    @Operation(summary = "刷新获取服务器网络状况")
    @GetMapping("/refresh_network")
    public R<NetworkInfoResponse> refreshNetwork() {
        return R.data(monitorService.refreshNetwork());
    }
}
